From eeaf9b069f51abe12cce571ff0682337d5c26898 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Fri, 6 Sep 2013 19:15:28 +0000 Subject: [PATCH] A very conservative move of xml_tag into a class of its own with headers of its own. Tweak xmalloc/xfree to new/delete. Regenerate deps. --- gpsbabel/Makefile.in | 29 +++++++++++++-------- gpsbabel/defs.h | 24 ----------------- gpsbabel/delbin.cc | 2 ++ gpsbabel/gpx.cc | 4 ++- gpsbabel/html.cc | 1 + gpsbabel/kml.cc | 1 + gpsbabel/src/core/xmltag.h | 53 ++++++++++++++++++++++++++++++++++++++ gpsbabel/text.cc | 1 + gpsbabel/util.cc | 1 + gpsbabel/xmltag.cc | 3 ++- 10 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 gpsbabel/src/core/xmltag.h diff --git a/gpsbabel/Makefile.in b/gpsbabel/Makefile.in index 6df5af759..9d95cf925 100644 --- a/gpsbabel/Makefile.in +++ b/gpsbabel/Makefile.in @@ -469,7 +469,8 @@ csv_util.o: csv_util.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ jeeps/gpsrqst.h jeeps/gpsinput.h jeeps/gpsproj.h garmin_fs.h \ jeeps/gps.h xcsv_tokens.gperf delbin.o: delbin.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h + gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \ + src/core/xmltag.h delgpl.o: delgpl.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h destinator.o: destinator.cc defs.h config.h queue.h zlib/zlib.h \ @@ -631,7 +632,8 @@ gpx.o: gpx.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ jeeps/gps.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h src/core/file.h defs.h src/core/xmlstreamwriter.h + jeeps/gpsproj.h src/core/file.h defs.h src/core/xmlstreamwriter.h \ + src/core/xmltag.h grtcirc.o: grtcirc.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \ grtcirc.h @@ -660,7 +662,7 @@ html.o: html.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h + jeeps/gpsproj.h src/core/xmltag.h humminbird.o: humminbird.cc defs.h config.h queue.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h \ src/core/datetime.h @@ -844,7 +846,8 @@ jtr.o: jtr.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h csv_util.h kml.o: kml.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h xmlgeneric.h \ - grtcirc.h src/core/file.h defs.h src/core/xmlstreamwriter.h + grtcirc.h src/core/file.h defs.h src/core/xmlstreamwriter.h \ + src/core/xmltag.h lmx.o: lmx.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h xmlgeneric.h lowranceusr.o: lowranceusr.cc defs.h config.h queue.h zlib/zlib.h \ @@ -1051,7 +1054,7 @@ text.o: text.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h + jeeps/gpsproj.h src/core/xmltag.h tiger.o: tiger.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \ csv_util.h @@ -1091,14 +1094,17 @@ units.o: units.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h util.o: util.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h \ - jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ - jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \ - jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \ - jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \ - jeeps/gpsproj.h + src/core/xmltag.h jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h \ + jeeps/gpsport.h jeeps/gpsdevice.h jeeps/gpssend.h jeeps/gpsread.h \ + jeeps/gpsutil.h jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h \ + jeeps/gpsfmt.h jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h \ + jeeps/gpsinput.h jeeps/gpsproj.h util_crc.o: util_crc.cc v900.o: v900.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h +validate.o: validate.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ + gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \ + filterdefs.h vcf.o: vcf.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h \ jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ @@ -1146,7 +1152,8 @@ xmlgeneric.o: xmlgeneric.cc defs.h config.h queue.h zlib/zlib.h \ zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h session.h \ src/core/datetime.h xmlgeneric.h src/core/file.h defs.h xmltag.o: xmltag.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h \ - gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h + gbfile.h cet.h cet_util.h inifile.h session.h src/core/datetime.h \ + src/core/xmltag.h xol.o: xol.cc defs.h config.h queue.h zlib/zlib.h zlib/zconf.h gbfile.h \ cet.h cet_util.h inifile.h session.h src/core/datetime.h xmlgeneric.h \ jeeps/gpsmath.h jeeps/gps.h jeeps/../defs.h jeeps/gpsport.h \ diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 60a841aa2..d17311e0e 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -305,18 +305,6 @@ public: QString personal_note; }; -typedef struct xml_tag { - char* tagname; - char* cdata; - int cdatalen; - char* parentcdata; - int parentcdatalen; - char** attributes; - struct xml_tag* parent; - struct xml_tag* sibling; - struct xml_tag* child; -} xml_tag ; - typedef void (*fs_destroy)(void*); typedef void (*fs_copy)(void**, void*); typedef void (*fs_convert)(void*); @@ -346,13 +334,6 @@ void fs_chain_destroy(format_specific_data* chain); format_specific_data* fs_chain_find(format_specific_data* chain, long type); void fs_chain_add(format_specific_data** chain, format_specific_data* data); -typedef struct fs_xml { - format_specific_data fs; - xml_tag* tag; -} fs_xml; - -fs_xml* fs_xml_alloc(long type); - #define FS_GPX 0x67707800L #define FS_AN1W 0x616e3177L #define FS_AN1L 0x616e316cL @@ -701,7 +682,6 @@ unsigned int waypt_count(void); void set_waypt_count(unsigned int nc); void waypt_add_url(waypoint* wpt, const QString& link, const QString& url_link_text); -void free_gpx_extras(xml_tag* tag); void xcsv_setup_internal_style(const char* style_buf); void xcsv_read_internal_style(const char* style_buf); waypoint* find_waypt_by_name(const char* name); @@ -1034,10 +1014,6 @@ const char* get_filename(const char* fname); /* extract the filename portion * /* this lives in gpx.c */ gpsbabel::DateTime xml_parse_time(const QString& cdatastr); -xml_tag* xml_findfirst(xml_tag* root, const char* tagname); -xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname); -char* xml_attribute(xml_tag* tag, const char* attrname); - char* rot13(const QString& str); /* diff --git a/gpsbabel/delbin.cc b/gpsbabel/delbin.cc index 18fccc694..4a4db13ac 100644 --- a/gpsbabel/delbin.cc +++ b/gpsbabel/delbin.cc @@ -21,6 +21,8 @@ */ #include "defs.h" +#include "src/core/xmltag.h" + #include #define MYNAME "delbin" diff --git a/gpsbabel/gpx.cc b/gpsbabel/gpx.cc index 297554e57..bb472e515 100644 --- a/gpsbabel/gpx.cc +++ b/gpsbabel/gpx.cc @@ -27,6 +27,8 @@ static QXmlStreamReader* reader; #include "src/core/file.h" #include "src/core/xmlstreamwriter.h" +#include "src/core/xmltag.h" + #include #include #include @@ -548,7 +550,7 @@ start_something_else(const QString el, const QXmlStreamAttributes& attr) return; } - new_tag = (xml_tag*)xcalloc(sizeof(xml_tag),1); + new_tag = new xml_tag; new_tag->tagname = xstrdup(CSTR(el)); attr_count = attr.size(); diff --git a/gpsbabel/html.cc b/gpsbabel/html.cc index 12c4d65f1..0e3b894cc 100644 --- a/gpsbabel/html.cc +++ b/gpsbabel/html.cc @@ -22,6 +22,7 @@ #include "defs.h" #include "jeeps/gpsmath.h" +#include "src/core/xmltag.h" #include static gbfile* file_out; diff --git a/gpsbabel/kml.cc b/gpsbabel/kml.cc index 3aa5cf5d5..005f5309b 100644 --- a/gpsbabel/kml.cc +++ b/gpsbabel/kml.cc @@ -34,6 +34,7 @@ #include "src/core/file.h" #include "src/core/xmlstreamwriter.h" +#include "src/core/xmltag.h" // options static char* opt_deficon = NULL; diff --git a/gpsbabel/src/core/xmltag.h b/gpsbabel/src/core/xmltag.h new file mode 100644 index 000000000..eba34eb6a --- /dev/null +++ b/gpsbabel/src/core/xmltag.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2013 Robert Lipe, gpsbabel.org + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA + + */ +class xml_tag { + public: + xml_tag() : + tagname(NULL), + cdata(NULL), + cdatalen(0), + parentcdata(NULL), + parentcdatalen(0), + attributes(NULL), + parent(NULL), + sibling(NULL), + child(NULL) {} + + char* tagname; + char* cdata; + int cdatalen; + char* parentcdata; + int parentcdatalen; + char** attributes; + struct xml_tag* parent; + struct xml_tag* sibling; + struct xml_tag* child; +}; + +xml_tag* xml_findfirst(xml_tag* root, const char* tagname); +xml_tag* xml_findnext(xml_tag* root, xml_tag* cur, const char* tagname); +char* xml_attribute(xml_tag* tag, const char* attrname); +void free_gpx_extras(xml_tag* tag); + +typedef struct fs_xml { + format_specific_data fs; + xml_tag* tag; +} fs_xml; + +fs_xml* fs_xml_alloc(long type); diff --git a/gpsbabel/text.cc b/gpsbabel/text.cc index 80f2910db..0b419b75a 100644 --- a/gpsbabel/text.cc +++ b/gpsbabel/text.cc @@ -22,6 +22,7 @@ #include "defs.h" #include "jeeps/gpsmath.h" +#include "src/core/xmltag.h" #include static gbfile* file_out; diff --git a/gpsbabel/util.cc b/gpsbabel/util.cc index a02b9498d..4d9aa9136 100644 --- a/gpsbabel/util.cc +++ b/gpsbabel/util.cc @@ -20,6 +20,7 @@ */ #include "defs.h" +#include "src/core/xmltag.h" #include "jeeps/gpsmath.h" #include diff --git a/gpsbabel/xmltag.cc b/gpsbabel/xmltag.cc index 8234aa539..810710b60 100644 --- a/gpsbabel/xmltag.cc +++ b/gpsbabel/xmltag.cc @@ -24,6 +24,7 @@ #include #include "defs.h" +#include "src/core/xmltag.h" static void free_xml_tag(xml_tag* tag) @@ -55,7 +56,7 @@ free_xml_tag(xml_tag* tag) } next = tag->sibling; - xfree(tag); + delete tag; tag = next; } } -- 2.30.2